package cn.gjxblog.aop.proxy.cglib;

import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.cglib.proxy.Enhancer;

/**
 *Spring对Cglib底层进行了集成，并修改了默认的Callback回调函数，
 *可以借助Spring中Cglib相关API，实现动态代理功能。
 *
 * @Author guojiaxun
 * @Date 2020/3/9 10:40
 */
public class TestCglib {

    public static void main(String[] args) {
        System.setProperty("cglib.debugLocation",System.getProperty("user.dir"));

        Enhancer enhancer = new Enhancer();
        enhancer.setCallback(new MyInterceptor(new UserServiceImpl()));
        enhancer.setSuperclass(UserServiceImpl.class);
        UserServiceImpl userService = (UserServiceImpl) enhancer.create();

        userService.getUser(1);
    }
}
